package com.Maykk.systemIO;

import java.io.*;
import java.util.Scanner;

/**
 * @ClassName: Demo02
 * @Description: TODO 输入内容存储到文件
 * @Author: MaykkStar@163.com
 */
public class Demo02 {
    public static void main(String[] args) throws IOException {
        // 定义一个缓冲区输入流
        // InputStream str = System.in;
        // InputStreamReader is = new InputStreamReader(str);
        // BufferedReader br = new BufferedReader(is);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        // 定义一个缓冲区输出流
        // OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream("./Maykk.txt"));
        // BufferedWriter bw = new BufferedWriter(ow);

        // BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("./Maykk.txt")));
        // FileWriter 等于自动封装 new OutputStreamWriter(new FileOutputStream())
        BufferedWriter bw = new BufferedWriter(new FileWriter("./Maykk.txt"));

        String str;
        // while ((str = br.readLine()).equals("over")) {
        //     bw.write(str);
        //     bw.newLine();
        //     bw.flush();
        // }

        System.out.print("请输入:");
        // str = new Scanner(System.in).next() // .next() 方法会被白空格（空格、回车、缩进等）截断
        while (!(str = new Scanner(System.in).nextLine()).equals("over")) {
            // str = new Scanner(System.in).nextLine();
            System.out.print("请输入:");
            bw.write(str);
            bw.newLine();
            bw.flush();
        }

        br.close();
        bw.close();
    }
}
